package com.letoken.platform.repo.app.manager;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.letoken.platform.repo.app.dao.AppVersionInfoMapper;
import com.letoken.platform.repo.app.po.AppVersion;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;


/**
 * 管理版本
 *
 * @author : hfanghao
 * @date : 2022-01-18 14:29
 **/
@Log4j2
@Repository
public class AppVersionInfoManager {

    @Autowired
    private AppVersionInfoMapper systemVersionInfoMapper;


    public AppVersion queryLastVersion(Integer client) {
        LambdaQueryWrapper<AppVersion> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(AppVersion::getClient, client)
                .orderByDesc(AppVersion::getCreateTime).last("limit 1");

        return systemVersionInfoMapper.selectOne(lambdaQueryWrapper);
    }
}
